//
//  ImportIdiomByTextViewController.swift
//  XingCeHelper
//
//  Created by 申铭 on 2022/10/18.
//

import UIKit

class ImportIdiomByTextViewController: UIViewController {

    @IBOutlet weak var textView: UITextView!
    @IBOutlet weak var importBtn: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        textView.text = ""
        textView.layer.borderColor = UIColor.systemGray5.cgColor
        textView.layer.borderWidth = 1.0
        
        importBtn.setTitle("导入", for: .normal)
    }

    @IBAction func pasteText(_ sender: Any) {
        textView.text = UIPasteboard.general.string
    }
    
    @IBAction func clickImportBtn(_ sender: Any) {
        guard let string = textView.text, !string.isEmpty else {
            print("字符串为空")
            return
        }
        
        print(string)
        ImportTool.importIdiom(string: string)
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        
        textView.resignFirstResponder()
    }
    
}
